package com.lovo.bbs.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * 统计在线人数
 * @author tiancen2001
 *
 */
public class VistorCounterListen implements HttpSessionListener {
	private static int visitorNum = 1; //在线人数

	public void sessionCreated(HttpSessionEvent arg0) {
		visitorNum++;
	}

	public void sessionDestroyed(HttpSessionEvent arg0) {
	   if(visitorNum>0){
		   visitorNum--;
	   }
	}
	
	/**
	 * 取得在线人数
	 * @return
	 */
	public static int getVisitorNum(){
		return visitorNum;
	}

}
